-wayland: Safeguard against NULL gtk_surface1
authorGeorges Basile Stavracas Neto <georges.stavracas@gmail.com>
Wed, 4 Oct 2017 21:25:31 +0000 (18:25 -0300)
committerGeorges Basile Stavracas Neto <georges.stavracas@gmail.com>
Wed, 4 Oct 2017 21:30:34 +0000 (18:30 -0300)
There is no guarantee that the gtk_surface won't be NULL,
and Wayland API does not safeguard against NULL, so we have
to do that ourselves here.

We were also mistakenly cheking for the surface version off
by one, fix that too by checking if the surface version is
equal or greater.

gdk/wayland/gdkwindow-wayland.c

index 50d6bd36b5058d4c0390dee964327056f37fa6b2..64f2b201a54a259dabd393114338710665993e10 100644 (file)
@@ -3644,8 +3644,12 @@ static gboolean
 gdk_wayland_window_supports_edge_constraints (GdkWindow *window)
 {
   GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
+  struct gtk_surface1 *gtk_surface = impl->display_server.gtk_surface;
 
-  return gtk_surface1_get_version (impl->display_server.gtk_surface) > GTK_SURFACE1_CONFIGURE_EDGES_SINCE_VERSION;
+  if (!gtk_surface)
+    return FALSE;
+
+  return gtk_surface1_get_version (gtk_surface) >= GTK_SURFACE1_CONFIGURE_EDGES_SINCE_VERSION;
 }
 
 static void